home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / tools / bison.lha / bison++-1.04 / getargs.c < prev    next >
C/C++ Source or Header  |  1989-06-09  |  2KB  |  105 lines

  1. /* Parse command line arguments for bison,
  2.    Copyright (C) 1984, 1986, 1989 Free Software Foundation, Inc.
  3.  
  4. This file is part of Bison, the GNU Compiler Compiler.
  5.  
  6. Bison is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. Bison is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with Bison; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include <stdio.h>
  22. #include "files.h"
  23.  
  24. int verboseflag;
  25. int definesflag;
  26. int debugflag;
  27. int nolinesflag;
  28. extern int fixed_outfiles;/* JF */
  29.  
  30. void
  31. getargs(argc, argv)
  32. int argc;
  33. char *argv[];
  34. {
  35.   register int c;
  36.   char *p = argv[0];
  37.   char *lastcomponent;
  38.  
  39.   extern int optind;
  40.   extern char *optarg;
  41.  
  42.   verboseflag = 0;
  43.   definesflag = 0;
  44.   debugflag = 0;
  45.   fixed_outfiles = 0;
  46.  
  47. #if 0 /* Let's avoid dependence on what name invoked with.
  48.      The file `yacc' can be a shell script that runs `bison -y'.  */
  49.   /* See if the program was invoked as "yacc".  */
  50.  
  51.   lastcomponent = p;
  52.   while (*p)
  53.     {
  54.       if (*p == '/')
  55.     lastcomponent = p + 1;
  56.       p++;
  57.     }
  58.   if (! strcmp (lastcomponent, "yacc"))
  59.     /* If so, pretend we have "-y" as argument.  */
  60.     fixed_outfiles = 1;
  61. #endif
  62.  
  63.   while ((c = getopt (argc, argv, "yvdlto:")) != EOF)
  64.     switch (c)
  65.       {
  66.       case 'y':
  67.     fixed_outfiles = 1;
  68.     break;
  69.  
  70.       case 'v':
  71.         if(optind && argv[optind] && !strcmp(argv[optind],"-version")) {
  72.       extern char *version_string;
  73.  
  74.       printf("%s",version_string);
  75.       while(getopt(argc,argv,"ersion")!='n')
  76.        ;
  77.     } else
  78.       verboseflag = 1;
  79.     break;
  80.  
  81.       case 'd':
  82.     definesflag = 1;
  83.     break;
  84.  
  85.       case 'l':
  86.     nolinesflag = 1;
  87.     break;
  88.  
  89.       case 't':
  90.     debugflag = 1;
  91.     break;
  92.  
  93.       case 'o':
  94.     spec_outfile = optarg;
  95.       }
  96.  
  97.   if (optind == argc)
  98.     fatal("grammar file not specified");
  99.   else
  100.     infile = argv[optind];
  101.  
  102.   if (optind < argc - 1)
  103.     fprintf(stderr, "bison: warning: extra arguments ignored\n");
  104. }
  105.